<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>到账时间配置</title>
	<%@ include file="/view/common/tags.jsp"%>
	<script type="text/javascript" src="${sysManagerV1}/js/My97DatePicker/WdatePicker.js"> </script>
</head>
<body>
	<section class="content">
    	<div class="row">
            <div class="col-md-12">
                <div class="box">
                	<div class="box-body">
						<div class="panel panel-default">
                            <div class="panel-body" style="padding-bottom:5px;">
                                <form class="form-horizontal" action="" method="post" id="dataForm">
                                    <input type="hidden" id="token" name="token" value=""/>
                                    <div class="searchMenu">
                                        <div>
                                            <label>游戏：</label>
                                            <sk:select cssClass="form-control select" name="wm[GAME_ID]" id="gameId" value="${page.wm.GAME_ID}" requiredInit="true" ajaxURL="${userInfoV1}/baseGame/gameSelect?wm[USE_FLAG]=1" onchange="TagUtil.fillOptions('gameId')">
                                                <option value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>交易类型：</label>
                                            <sk:select cssClass="form-control select" id="tradeId" name="wm[TRADE_ID]" value="${page.wm.TRADE_ID}" parentCascadedSelect="gameId" parentParamName="gameId" requiredInit="true" ajaxURL="${tradeV1}/tradeState/gameTradeTypeDictList">
                                                <option value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>商品主类：</label>
                                            <sk:select cssClass="form-control select" id="baseTypeId" name="wm[BASE_TYPE_ID]" value="${page.wm.BASE_TYPE_ID}" parentCascadedSelect="gameId" parentParamName="wm[GAME_ID]" ajaxURL="${userInfoV1}/gameGoodsType/baseTypeSelect?wm[OPEN_FLAG]=1&wm[DEL_FLAG]=0" onchange="setAjxaUrl('bigTypeId', 'gameId'); TagUtil.fillOptions('baseTypeId');">
                                                <option value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>商品大类：</label>
                                            <sk:select cssClass="form-control select" id="bigTypeId" name="wm[BIG_TYPE_ID]" value="${page.wm.BIG_TYPE_ID}" parentCascadedSelect="baseTypeId" parentParamName="wm[TYPE_FLAG]" ajaxURL="${userInfoV1}/gameGoodsType/typeSelect?wm[OPEN_FLAG]=1&wm[DEL_FLAG]=0" onchange="setAjxaUrl('smallTypeId', 'gameId'); TagUtil.fillOptions('bigTypeId')">
                                                <option value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>商品小类：</label>
                                            <sk:select cssClass="form-control select" id="smallTypeId" name="wm[SMALL_TYPE_ID]" value="${page.wm.SMALL_TYPE_ID}" parentCascadedSelect="bigTypeId" parentParamName="wm[PARENT_ID]" ajaxURL="${userInfoV1}/gameGoodsType/smallTypeSelect?wm[OPEN_FLAG]=1&wm[DEL_FLAG]=0">
                                                <option value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div class="mal10" >
                                            <button type="button"  class="btn btn-primary btn-sm" onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
                                            <sk:button type="button" rightKey="20170816153140" _class="btn btn-success btn-sm" onclick="add()"><span class='glyphicon glyphicon-plus'></span>添&nbsp;加</sk:button>
                                        </div>
                                	</div>
                                </form>
                            </div>
						</div>
                        <table class="table table-hover table-condensed table-bordered" id="dataTable" >
                            <thead>
                            	<tr>
                                	<th data-field="index" data-align="center" data-sortable="false" data-formatter="indexFormatter" >序号</th>
                                	<th data-field="gameName" data-align="center" data-sortable="true">游戏</th>
                                	<th data-field="tradeName" data-align="center" data-sortable="true">交易类型</th>
                                	<th data-field="bigTypeName" data-align="center" data-sortable="true">商品大类</th>
                                	<th data-field="smallTypeName" data-align="center" data-sortable="true">商品小类</th>
                                    <th data-field="ysLimit" data-align="center" data-sortable="true">到账时间（分）</th>
                                    <th data-field="operatorAccount" data-align="center" data-sortable="true">操作人</th>
                                    <th data-field="operatorTime" data-align="center" data-sortable="true">操作时间</th>
                                    <th data-field="deleteButton" data-align="center"  data-formatter="buttonFormatter" data-sortable="false">操作</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
       	</div>
	</section>
   <%@ include file="/view/common/footer.jsp"%>
</body>
<script>
	// 提示信息
	var msgg='<%=request.getAttribute("msg")%>';
	if (msgg && msgg!=null && msgg!='null') { 
		  layer.msg(msgg);
	}
	var tableIndex = 0; // 添加修改的弹出框的ID
	
	// 加载table 数据
    $(function(){
        $("#token").val(sessionStorage.getItem("token"));

        $("#dataTable").bootstrapTable({
            url: "${tradeV1}/tradeBaseToAccountSafetyConfig/data.json",
            method:"get",
            pagination:true,
            sidePagination:"server",
            queryParams: function(params) {
                return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));
            }
        });
    })
    
	// 操作 字段格式化
    function buttonFormatter(value, row, index) {
        var caozuo2 = "<button id='btn_edit' type='button' onclick='_update("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>修 改</button>";
        return caozuo2 ;
    }

    // 查询
    function findData(){
       $("#dataTable").bootstrapTable("refresh",{} ); 
    } 

    // 行点击事件
    $(function(){
         $("body").on("click","table>tbody>tr",function(){
          $(this).css("background","#e1ecf1").siblings().css("background","");
       });
    })
    
    // 弹出添加的窗口
    function add(){
    	tableIndex = layer.open({
            type: 2,
            title: "添加到账",
            closeBtn: 1,
            shadeClose: true,
            area: ['650px', '320px'],
            content: "${sysManagerV1}/baseAccountSafety/toAdd?rowId=0",
            btn: ["确 认","关 闭"], 
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }
    
    // 弹出添加的窗口      修改功能
    function _update(rowId){
    	tableIndex = layer.open({
            type: 2,
            title: "修改到账",
            closeBtn: 1,
            shadeClose: true,
            area: ['650px', '320px'],
            content: "${sysManagerV1}/baseAccountSafety/toAdd?rowId=" + rowId,
            btn: ["确 认","关 闭"], 
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }
    
    // 给目标select的ajaxURL 加参数
    function setAjxaUrl(keyId, valueId){
    	var gameId = $("#" + valueId).find("option:selected").val();
    	var ajaxURL = $("#" + keyId).attr("ajaxURL");
    	if(ajaxURL.indexOf("GAME_ID") < 0){
    	    ajaxURL += "&wm[GAME_ID]=" + gameId;
    	} else {
    		var valueTemp = ajaxURL.substring(ajaxURL.indexOf("wm[GAME_ID]="));
    		if(valueTemp.indexOf("&") >= 0){
    			valueTemp = valueTemp.substr(valueTemp.indexOf("=") + 1, valueTemp.indexOf("&"));
    		}
    		ajaxURL = ajaxURL.replace(valueTemp, "wm[GAME_ID]=" + gameId);
    	}
      	$("#" + keyId).attr("ajaxURL", ajaxURL);
    }
</script>
</html>